<?php

/**
 * This is the model class for table "firstaidfireprotection".
 *
 * The followings are the available columns in table 'firstaidfireprotection':
 * @property integer $Id
 * @property string $FirstAidType
 * @property string $Capacity
 * @property integer $NoOfUnits
 * @property integer $WithPSMark
 * @property integer $WithISOMark
 * @property integer $ProperlyMaintained
 * @property integer $ConspicuouslyLocated
 * @property integer $FirstAidAccessible
 * @property string $OtherTypes
 * @property integer $Establishment_Id
 *
 * The followings are the available model relations:
 * @property Establishments $establishment
 */
class Firstaidfireprotection extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Firstaidfireprotection the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'firstaidfireprotection';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NoOfUnits, WithPSMark, WithISOMark, ProperlyMaintained, ConspicuouslyLocated, FirstAidAccessible, Establishment_Id', 'numerical', 'integerOnly'=>true),
			array('FirstAidType, Capacity', 'length', 'max'=>60),
			array('OtherTypes', 'length', 'max'=>150),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('Id, FirstAidType, Capacity, NoOfUnits, WithPSMark, WithISOMark, ProperlyMaintained, ConspicuouslyLocated, FirstAidAccessible, OtherTypes, Establishment_Id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'establishment' => array(self::BELONGS_TO, 'Establishments', 'Establishment_Id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'FirstAidType' => 'First Aid Type',
			'Capacity' => 'Capacity',
			'NoOfUnits' => 'No Of Units',
			'WithPSMark' => 'With Psmark',
			'WithISOMark' => 'With Isomark',
			'ProperlyMaintained' => 'Properly Maintained',
			'ConspicuouslyLocated' => 'Conspicuously Located',
			'FirstAidAccessible' => 'First Aid Accessible',
			'OtherTypes' => 'Other Types',
			'Establishment_Id' => 'Establishment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('FirstAidType',$this->FirstAidType,true);
		$criteria->compare('Capacity',$this->Capacity,true);
		$criteria->compare('NoOfUnits',$this->NoOfUnits);
		$criteria->compare('WithPSMark',$this->WithPSMark);
		$criteria->compare('WithISOMark',$this->WithISOMark);
		$criteria->compare('ProperlyMaintained',$this->ProperlyMaintained);
		$criteria->compare('ConspicuouslyLocated',$this->ConspicuouslyLocated);
		$criteria->compare('FirstAidAccessible',$this->FirstAidAccessible);
		$criteria->compare('OtherTypes',$this->OtherTypes,true);
		$criteria->compare('Establishment_Id',$this->Establishment_Id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}